package com.uam.web.controller;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.util.JSONPObject;
import com.uam.common.config.UAMConfig;
import com.uam.service.IDataLayerBcService;
import com.uam.utils.FileToStringUtils;
import com.uam.utils.StringUtils;
import com.uam.web.common.model.Result;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.File;
import java.io.IOException;

/**
 *
 * @author uam
 * @date 2023-11-22
 */
@Controller
@RequestMapping("/mock/")
@Api(tags = "静态资源访问目录")
@Slf4j
public class MockController extends BaseController {
    @Autowired
    private UAMConfig uamConfig;
    @ApiOperation(value = "查看数据列表")
    @GetMapping("vertipad/{fileName}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "用户登录token", paramType = "header"),
    })
    @ResponseBody
    public String info(@ApiParam(value = "文件名", required = true) @PathVariable String fileName) throws IOException {
        log.info("fileName:{}",uamConfig.getStaticResourceJsonPath()+"/"+fileName);
        String data = FileToStringUtils.txt2String(uamConfig.getStaticResourceJsonPath()+"/"+fileName);
        log.info("data:{}",data);
        if (StringUtils.isBlank(data)) { throw new RuntimeException("文件不存在"); }
//        JSONObject jsonObject = JSONObject.parseObject(data).getJSONObject("data");
        return data;
    }


}
